package com.zyl.Ecs.common.domain.device.ext;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zyl.Ecs.common.domain.device.bean.Position;
import com.zyl.Ecs.common.domain.device.vo.PositionVO;
import com.zyl.Ecs.common.utils.CUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

import java.util.List;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.device.domain.ext
 * @ClassName: PositionExt
 * @Description TODO (位置扩展类)
 * @Author 翟玉龙
 * @Date 2024/12/5-9:32
 */
@Data
@ToString
@SuperBuilder
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(value = "ecs_position")
public class PositionExt extends Position {

    /**
     * 包含的传感器ID列表（入参）
     */
    @TableField(exist = false)
    private List<Integer> sensorIds;

    /**
     * 所属车间（出参）
     */
    @TableField(exist = false)
    private RoomExt room;

    /**
     * 包含的传感器列表（出参）
     */
    @TableField(exist = false)
    private List<SensorExt> sensors;


    public static PositionExt toExt(Position position) {
        return CUtil.copyBean(position, PositionExt.class);
    }

    public static PositionExt toExt(PositionVO positionVO) {
        return PositionExt.builder()
                .id(positionVO.getId())
                .name(positionVO.getName())
                .roomId(positionVO.getRoomId())
                .sensorIds(positionVO.getSensorIds())
                .build();
    }

}

